1. Field of the Invention
The present invention relates to a microcomputer comprising of a semiconductor integrated circuit and more particularly relates to controlling the operation of a timer provided in a microcomputer.
2. Description of the Related Art
Microcomputers have input ports, output ports, memory and Central Processing Units (hereinafter referred to as xe2x80x9cCPU""sxe2x80x9d) and are operated under software control to perform various functions. Microcomputers therefore have a wide range of applications in control of the operation of household appliances and control of vehicle engines, etc.
Microcomputers are also provided with timers for controlling the timing of the operation of various functions. Timer circuits provided in microcomputers are, for example, input timers and output timers.
An input timer has a function for counting the number of pulses of a clock signal using a counter. An input timer transfers a number of pulses counted at a counter for outputting in response to the detection of a transition (for example, a falling edge from a level of a power supply voltage VDD to the level of an earth voltage VSS) of the voltage level of a pulse signal externally inputted via an input port, i.e. transferring of a count value for a number of pulses transferred in intervals occurring on transitions in the voltage level of the pulse signal inputted from one of the input ports can be carried out. The intervals between the occurrence of an external input signal can therefore be confirmed from the output of the register that is the output of the input timer.
Input timers are also used, for example, in microcomputers for use with vehicles in order to obtain the speed of a piston operation occurring in a cylinder of an ignition chamber used in an engine unit, i.e. a signal outputted in accompaniment with one piston operation is used as a pulse signal inputted from one of the input ports and the speed of the piston operation can be obtained by carrying out arithmetic processing using a count value stored in the register of the input timer.
Output timers have a function for counting the number of pulses of a clock signal using a counter. An output timer then outputs a signal indicating coincidence when the number of pulses counted by the timer coincides with a prescribed set pulse number.
In, for example, microcomputers for use with vehicles, an output timer is used in order to designate control of the timing of ignitions of a spark plug in a combustion chamber used in an engine unit, i.e. a signal indicating coincidence from an output timer is utilized in order to time ignitions of a spark plug in response to the prescribed set number of pulses in an effective manner.
When both the input timer and the output timer are used to control an engine unit in the above way, it is preferable to link mutual operations in order to make controlling the respective operations straightforward.
However, applications where each timer can be put to use are by no means limited to the above. Various demands are therefore made by the users, such as control of the operations in such a manner that the two timers are linked, control of the respective timer operations using software, and control of the respective timer operations using signals from outside of the microcomputer.
For example, when two external input signals for controlling the respective operations of the input timer and the output timer are prepared at peripheral circuits of a microcomputer, demands are made to control the operation of the respective timers using the two external input signals. Further, when a program for controlling the operation of the two timers is built into programmable memory within the microcomputer, control of the operation of the respective timers using software is demanded.
It is therefore an object of the present invention to provide a microcomputer capable of arbitrarily selecting methods of controlling operation of the timer functions and that can be put to a wide range of practical uses.
It is a further object of the present invention to achieve the aforementioned object without bringing about increases in circuit scale of increasing the complexity of control.
In order to realize the above object, the microcomputer of the present invention comprises a first timer circuit for outputting a count value counted for a number of clocks for a clock signal based on a transition indication signal indicating a transition of a voltage level of an externally inputted pulse signal, a second timer circuit operating in response to a count permit signal and outputting an output signal when the count value counted for the number of clocks of the clock signal becomes a prescribed count value and a select circuit for outputting one of a plurality of signals including the transition indication signal and an internally generated signal as a count permit signal for controlling the operation of counting the number of clocks of the clock signal.
In the microcomputer of the present invention, generation of the internally generated signal can be controlled by software.
The select circuit of the microcomputer of the present invention can output one of the plurality of signals as the count permit signal in response to the select indication signal.
Further, in the microcomputer of the present invention, the plurality of signals can include an externally inputted signal different from the pulse signal.
Still further, in the microcomputer of the present invention, the first timer circuit can comprise a dividing circuit for outputting a divided signal divided from the transition indication signal, and outputs the count value in response to the divided signal, with the divided signal being included in the plurality of signals selected by the select circuit.